﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using GU.WebERP.Dict;

namespace GU.WebERP.Model
{
    [Serializable]
    public class Model_Fct_User : JnsFramework.Common.IModel
    {
        /// <summary>
        /// Description:用户自增 ID  
        /// </summary>
        public int UserId
        {
            get;
            set;
        }

        /// <summary>
        /// Description:用户名  
        /// </summary>
        public string UserName
        {
            get;
            set;
        }

        /// <summary>
        /// Description:用户密码  MD5 值  
        /// </summary>
        public string Password
        {
            get;
            set;
        }

        /// <summary>
        /// Description:用户菜单  
        /// </summary>
        public string MenuRights
        {
            get;
            set;
        }

        /// <summary>
        /// Description:是否为管理员，若为管理员，则显示所有菜单  1 ：是管理员   0：不是管理员  
        /// </summary>
        public int IsAdmin
        {
            get;
            set;
        }

        /// <summary>
        /// Description:备注  
        /// </summary>
        public string Remark
        {
            get;
            set;
        }

        /// <summary>
        /// Description:是否已被删除  1：已删除   0 ：未删除  
        /// </summary>
        public int Disabled
        {
            get;
            set;
        }

        /// <summary>
        /// Description:创建时间  
        /// </summary>
        public DateTime Rec_CreateTime
        {
            get;
            set;
        }

        /// <summary>
        /// Description:创建人  
        /// </summary>
        public string Rec_CreateBy
        {
            get;
            set;
        }

        /// <summary>
        /// Description:修改时间  
        /// </summary>
        public DateTime Rec_ModifyTime
        {
            get;
            set;
        }

        /// <summary>
        /// Description:记录修改人  
        /// </summary>
        public string Rec_ModifyBy
        {
            get;
            set;
        }

        private List<MiniUi_Menu> _UserMenu = null;


        public List<MiniUi_Menu> UserMenu
        {
            get
            {
                return _UserMenu;
            }
            set
            {
                _UserMenu = value;
            }
        }

        public static Model_Fct_User TableToModel(DataTable dtFct_User)
        {
            if (dtFct_User != null && dtFct_User.Rows.Count > 0)
            {
                return TableRowToModel(dtFct_User.Rows[0]);
            }
            else
            {
                return null;
            }
        }

        public static Model_Fct_User TableRowToModel(DataRow drFct_User)
        {
            Model_Fct_User mFct_User = new Model_Fct_User();
            if (drFct_User[Dict_Fct_User.UserId] != null && drFct_User[Dict_Fct_User.UserId].ToString() != "")
            {
                mFct_User.UserId = Convert.ToInt32(drFct_User[Dict_Fct_User.UserId].ToString());
            }
            if (drFct_User[Dict_Fct_User.UserName] != null && drFct_User[Dict_Fct_User.UserName].ToString() != "")
            {
                mFct_User.UserName = drFct_User[Dict_Fct_User.UserName].ToString();
            }
            if (drFct_User[Dict_Fct_User.Password] != null && drFct_User[Dict_Fct_User.Password].ToString() != "")
            {
                mFct_User.Password = drFct_User[Dict_Fct_User.Password].ToString();
            }
            if (drFct_User[Dict_Fct_User.MenuRights] != null && drFct_User[Dict_Fct_User.MenuRights].ToString() != "")
            {
                mFct_User.MenuRights = drFct_User[Dict_Fct_User.MenuRights].ToString();
            }
            if (drFct_User[Dict_Fct_User.IsAdmin] != null && drFct_User[Dict_Fct_User.IsAdmin].ToString() != "")
            {
                mFct_User.IsAdmin = Convert.ToInt32(drFct_User[Dict_Fct_User.IsAdmin].ToString());
            }
            if (drFct_User[Dict_Fct_User.Remark] != null && drFct_User[Dict_Fct_User.Remark].ToString() != "")
            {
                mFct_User.Remark = drFct_User[Dict_Fct_User.Remark].ToString();
            }
            if (drFct_User[Dict_Fct_User.Disabled] != null && drFct_User[Dict_Fct_User.Disabled].ToString() != "")
            {
                mFct_User.Disabled = Convert.ToInt32(drFct_User[Dict_Fct_User.Disabled].ToString());
            }
            if (drFct_User[Dict_Fct_User.Rec_CreateTime] != null && drFct_User[Dict_Fct_User.Rec_CreateTime].ToString() != "")
            {
                mFct_User.Rec_CreateTime = Convert.ToDateTime(drFct_User[Dict_Fct_User.Rec_CreateTime].ToString());
            }
            if (drFct_User[Dict_Fct_User.Rec_CreateBy] != null && drFct_User[Dict_Fct_User.Rec_CreateBy].ToString() != "")
            {
                mFct_User.Rec_CreateBy = drFct_User[Dict_Fct_User.Rec_CreateBy].ToString();
            }
            if (drFct_User[Dict_Fct_User.Rec_ModifyTime] != null && drFct_User[Dict_Fct_User.Rec_ModifyTime].ToString() != "")
            {
                mFct_User.Rec_ModifyTime = Convert.ToDateTime(drFct_User[Dict_Fct_User.Rec_ModifyTime].ToString());
            }
            if (drFct_User[Dict_Fct_User.Rec_ModifyBy] != null && drFct_User[Dict_Fct_User.Rec_ModifyBy].ToString() != "")
            {
                mFct_User.Rec_ModifyBy = drFct_User[Dict_Fct_User.Rec_ModifyBy].ToString();
            }
            return mFct_User;
        }

        #region IModel 成员

        public string TableName
        {
            get { return "Fct_User"; }
        }

        public string[] Columns
        {
            get { return new string[] { "UserId", "UserName", "Password", "MenuRights", "IsAdmin", "Remark", "Disabled", "Rec_CreateTime", "Rec_CreateBy", "Rec_ModifyTime", "Rec_ModifyBy" }; }
        }

        #endregion
    }
}
